//
//  SMHDataView.swift
//  SMHCommerce
//
//  Created by lvzhao on 2020/6/2.
//  Copyright © 2020 lvzhao. All rights reserved.
//

import UIKit

class SMHDataView: LZBaseView {

    var viewModel = SMHDataViewModel()
       
    override init(viewModel: LZBaseViewModel) {
        super.init(viewModel: viewModel)
        self.viewModel = viewModel as! SMHDataViewModel
        setupUI()

    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI()  {
        
        let scrollView = UIScrollView()
        self.addSubview(scrollView)
        
        scrollView.snp.makeConstraints { (make) in
            make.edges.equalTo(self)
        }

        let contentView = UIView()
        // 添加容器视图
        scrollView.addSubview(contentView)
        contentView.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(scrollView)
            make.left.right.equalTo(self) // 确定的宽度，因为垂直滚动
        }
        
    
        
        

        //MARK: - 个人信息
        let personView = SMHDataPersonInfoView.init(viewModel: self.viewModel)
        contentView.addSubview(personView)
        personView.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.left.equalTo(0)
            make.height.equalTo(230)
            make.width.equalTo(kScreenWidth)
        }


        //MARK: - 销售额
        let salesView = SMHDataSalesInfoView.init(viewModel: self.viewModel)
        contentView.addSubview(salesView)
        salesView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.height.equalTo(295)
            make.width.equalTo(kScreenWidth)
            make.top.equalTo(personView.snp.bottom).offset(20)
            make.bottom.equalToSuperview().offset(-34)
        }

    }

}
